#!/usr/bin/env bash
# Copyright (c) Microsoft. All rights reserved.
# Note: Windows Bash doesn't support shebang extra params
set -e

# Note: use lowercase names for the Docker images
DOCKER_IMAGE="azureiotpcs/telemetry-dotnet"

APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && cd .. && pwd )/"
source "$APP_HOME/scripts/.functions.sh"

run_container() {
    check_dependency_docker

    $APP_HOME/scripts/env-vars-check

    echo "Starting Telemetry service..."
    docker run -it -p 9004:9004 \
        -e PCS_AUTH_WEBSERVICE_URL \
        -e PCS_STORAGEADAPTER_WEBSERVICE_URL \
        -e PCS_DIAGNOSTICS_WEBSERVICE_URL \
        -e PCS_TELEMETRY_DOCUMENTDB_CONNSTRING \
        -e PCS_AUTH_ISSUER \
        -e PCS_AUTH_AUDIENCE \
        -e PCS_AUTH_REQUIRED \
        -e PCS_CORS_WHITELIST \
        -e PCS_APPLICATION_SECRET \
        -e PCS_AAD_TENANT \
        -e PCS_AAD_APPID \
        -e PCS_AAD_APPSECRET \
        -e PCS_TELEMETRY_STORAGE_TYPE \
        -e PCS_TSI_FQDN \
        -e PCS_AZUREBLOB_CONNSTRING \
        -e PCS_ACTION_EVENTHUB_CONNSTRING \
        -e PCS_ACTION_EVENTHUB_NAME \
        -e PCS_LOGICAPP_ENDPOINT_URL \
        -e PCS_SOLUTION_WEBSITE_URL \
        "$DOCKER_IMAGE:testing"
}

run_container
